// pages/order_detail/order_detail.js
var app ;
var url;
var headers, order_no;

Page({
  data:{
    order_no:"",
    info:{},
    url:"https://app1.sztravel.com.cn/file/weixinapp/img"
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
    order_no = options.order_no;
  },
  onReady:function(){
    // 页面渲染完成
  },
  toPay:function(){
    var info=this.data.info;
    var orderMes = {
      title: info.title,
      time_start: info.time_start,
      depart: info.depart,
      total_num: info.tourist_num,
      total_price: info.price,
      order_no:order_no
    }
    console.log(orderMes)
    try {
      wx.setStorageSync("orderMes", JSON.stringify(orderMes))
    } catch (e) {
    }
    wx.navigateTo({
      url: '../pay/pay',
    })
  },
  onShow:function(){
    // 页面显示
    app = getApp();
    url = app.globalData.url
    var that = this
    headers = app.globalData.headers;
   
    wx.request({
      url: url + 'api/get_order_detail',
      method: "POST",
      header: headers,
      data: {
        "order_no": "" + order_no + ""
      },
      success: function (data) {
        console.log(data)
        if (data.data.result === 1) {
          that.setData({
            info: data.data.data
          })
        } else {
          wx.showModal({
            title: "来自伴行的提示",
            content: data.data.message,
            showCancel: false,
          });
        };
      }
    })
    console.log(this.data);
    
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  }
})